package cn.easy.rpc.config;

import lombok.SneakyThrows;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * @author zwb
 * @create 2020-09-05 21:04
 **/
@Component
public class ConfigAcceptor implements EnvironmentAware {

    @Override
    @SneakyThrows
    public void setEnvironment(Environment environment) {
        String port = environment.getProperty(ConfigHolder.SERVICE_CENTER_PORT);
        Assert.notNull(port,"service center port can not be null");
        ConfigHolder.serviceCenterPort = Integer.parseInt(port);
    }
}
